Keir Fraser [Wed, 17 Dec 2008 11:36:22 +0000 (11:36 +0000)]
x86, hvm: Don't ever call the shadow code to fix a page fault in an
external-mode guest if the fault came from Xen; it would be making
changes to the wrong pagetables, potentially causing a pagefault loop
in Xen.
Keir Fraser [Tue, 16 Dec 2008 13:14:25 +0000 (13:14 +0000)]
xenpm: add cpu frequency control interface, through which user can
tune the parameters manually.
Now, xenpm can be invoked with the following options:
Usage:
xenpm get-cpuidle-states [cpuid]: list cpu idle information on
CPU cpuid or all CPUs.
xenpm get-cpufreq-states [cpuid]: list cpu frequency
information on CPU cpuid or all CPUs.
xenpm get-cpufreq-para [cpuid]: list cpu frequency information
on CPU cpuid or all CPUs.
xenpm set-scaling-maxfreq <cpuid> <HZ>: set max cpu frequency
<HZ> on CPU <cpuid>.
xenpm set-scaling-minfreq <cpuid> <HZ>: set min cpu frequency
<HZ> on CPU <cpuid>.
xenpm set-scaling-governor <cpuid> <name>: set scaling governor
on CPU <cpuid>.
xenpm set-scaling-speed <cpuid> <num>: set scaling speed on CPU
<cpuid>.
xenpm set-sampling-rate <cpuid> <num>: set sampling rate on CPU
<cpuid>.
xenpm set-up-threshold <cpuid> <num>: set up threshold on CPU
<cpuid>.
To ease the use of this tool, the shortcut option is supported,
i.e. `xenpm get-cpui' is equal to `xenpm get-cpuidle-states'.
Keir Fraser [Mon, 15 Dec 2008 11:23:22 +0000 (11:23 +0000)]
rombios: fix references to EBDA
Extended Bios Data Area (EBDA) can be relocated by the initialization
of PCI option ROM. The IPL boot table is also.
EBDA must be accessed via 0x40E after the initialization.
Keir Fraser [Thu, 11 Dec 2008 13:25:28 +0000 (13:25 +0000)]
x86: enable interrupts explicitly in __start_xen()
Instead of relying on smp_prepare_cpus() (via check_nmi_watchdog()) or
init_xen_time() (via init_platform_timer() -> plt_overflow())
implicitly enabling interrupts, enable them explicitly once safe to do
so (it may actually be possible to move this even further up, but I
don't think that would buy us much).
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Also move spin_debug_enable() a bit higer. Moving it above
smp_prepare_cpus() didn't work for some reason though!
Keir Fraser [Thu, 11 Dec 2008 11:40:10 +0000 (11:40 +0000)]
x86: fix the potential of encountering panic "IO-APIC + timer doesn't work! ..."
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Linux commit:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=4aae07025265151e3f7041dfbf0f529e122de1d8
Under rare circumstances we found we could have an IRQ0 entry while we
are in the middle of setting up the local APIC, the i8259A and the
PIT. That is certainly not how it's supposed to work! check_timer()
was supposed to be called with irqs turned off - but this eroded away
sometime in the past. This code would still work most of the time
because this code runs very quickly, but just the right timing
conditions are present and IRQ0 hits in this small, ~30 usecs window,
timer irqs stop and the system does not boot up. Also, given how early
this is during bootup, the hang is very deterministic - but it would
only occur on certain machines (and certain configs).
The fix was quite simple: disable/restore interrupts properly in this
function. With that in place the test-system now boots up just fine.
Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Keir Fraser [Thu, 11 Dec 2008 11:36:00 +0000 (11:36 +0000)]
x86: unify local_irq_XXX()
This also removes an inconsistency in that x86-64's __save_flags() had
a memory clobber, while x86_32's didn't.
It further adds type checking since blindly using {pop,push}{l,q} on a
memory operand of unknown size bares the risk of corrupting other
data.
Finally, it eliminates the redundant (with local_irq_restore())
__restore_flags() macro and renames __save_flags() to
local_save_flags(), making the naming consistent with Linux (again?).
Keir Fraser [Thu, 11 Dec 2008 11:19:01 +0000 (11:19 +0000)]
Fix BUILD_BUG_ON()
As was noticed on the Linux side, using an array here isn't appropriate
if the condition is not a compile time constant - gcc allows such
arrays, and hence the intended effect of producing a compiler error is
not achieved in that case. Bit field widths do not know similar
language extensions, and hence always produce a compiler error.
Keir Fraser [Wed, 10 Dec 2008 13:41:34 +0000 (13:41 +0000)]
Initialize state_entry_time to zero for all idle vcpus
NOW() is not usable since xen time sub-system hasn't
been initialized yet. On my box, it gives a initial
stamp ~60s due to local tsc stamp as zero and TSC
count is started from power on. Then a negative value
is added to runstate of that idle vcpu at schedule
point. The net effect is for some tool like xenpm
to show a big idle time gap between BSP and other APs.
Signed-off-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
This patch add 3 more governors beside original running ondemand
cpufreq governor.
performance governor is with best performance, keeping cpu always
running at highest freq;
powersave governor is with best power save effect, keeping cpu always
running at lowest freq;
userspace governor provide user setting freq ability;
Keir Fraser [Tue, 9 Dec 2008 16:28:02 +0000 (16:28 +0000)]
Use virtual 8086 mode for VMX guests with CR0.PE == 0
When a VMX guest tries to enter real mode, put it in virtual 8086 mode
instead, if that's possible. Handle all errors and corner cases by
falling back to the real-mode emulator.
This is similar to the old VMXASSIST system except it uses Xen's
x86_emulate emulator instead of having a partial emulator in the guest
firmware. It more than doubles the speed of real-mode operation on
VMX.
Keir Fraser [Tue, 9 Dec 2008 12:45:45 +0000 (12:45 +0000)]
xend: Remember bootable flag for vbds in xenstore
When xend is restarted, bootable flags of all disk devices are lost
and then the first disk is marked as bootable by a "compatibility
hack". When a guest domain is created with a mixture of several vbd
and tap devices, the compatibility hack may fail to choose the right
bootable device. Thus preventing the guest to be restarted. This patch
fixes this behavior by remembering bootable flag for each disk device
in xenstore database.
Keir Fraser [Tue, 9 Dec 2008 12:44:32 +0000 (12:44 +0000)]
xend: Fix memory allocation bug after hvm reboot in numa system
Recently we find a bug on Nahelem machine (totally with two nodes, 6G
memory (3G in each node):
- Start a HVM guest with its all VCPUS pinned to node1, so all its
memory is allocated from node1.
- Reboot the HVM.
- There will be some memory allocated from node0 even there is enough
free memory on node1.
Reason: For security issues, xen will not put all the pages of a dying
hvm to domheap directly, but put them in scrub list and wait for handled
by page_scrub_softirq(). If the dying hvm have a lot of memory,
page_scrub_softirq() will not handle all of them before the start the
hvm. There are some pages belong to node1 still in scrub list, new hvm
can't use pages in it. So this hvm will get different memory
distribution than before. Before changeset 18304, page_scrub_softirq()
can be excuted parallel between all the cpus. Changeset 18305
serialise page_scrub_softirq() and Changeset 18307 serialise
page_scrub_softirq() with a new lock to avoid holding up acquiring
page_scrub_lock in free_domheap_pages(). Those changeset slow the ability
to handle pages in scrub list. So the bug becomes more obvious after.
Patch: This patch modifiers balloon.free to avoid this bug. After
patch, balloon.free will check whether current machine is a numa
system and the new created hvm has all its vcpus in the same node. If
all the conditions above fit, we will wait until all the pages in
scrub list are freed (if waiting time go beyond 20s, we will stop
waiting it.).
This seems to be too restricted at the first glance. We used to only
wait for the free memory size of pinned node is bigger than
required. But as we know HVM memory alloction granularity is 2M. Even
the former condition is satisfied, we still may not find enough
2M-size memory on that node.
Signed-off-by: Ting Zhou <ting.g.zhou@intel.com> Signed-off-by: Xiaowei Yang <Xiaowei.yang@intel.com>
Keir Fraser [Fri, 5 Dec 2008 15:23:32 +0000 (15:23 +0000)]
cpufreq: allow customization of some parameters
Short of having a way for powersaved to dynamically adjust these
values, at least allow specifying them on the command line. In
particular, always running at an up-threshold of 80% is perhaps nice
for laptop use, but certainly not desirable on servers. On shell
scripts invoking large numbers of short-lived processes I noticed a
50% performance degradation on a dual-socket quad-core Barcelona just
because of the load of an individual core never crossing the 80%
boundary that would have resulted in increasing the frequency.
(Powersaved on SLE10 sets this on native kernels to 60% or 80%,
depending on whether performance or power reduction is preferred,
*divided* by the number of CPUs, but capped at the lower limit of
20%.)
Keir Fraser [Thu, 4 Dec 2008 14:12:08 +0000 (14:12 +0000)]
Fix one timer range issue
According to the timer sematic, the timer can be executed at any timer
within [expires, expires_end], however, current implementation only allow
timer to be executed after expires_end, which is not conform to the timer
semantics.
This patch fix the the SPECpower score regression (~5% downgrade)
introduced by changeset 18744 "Change timer implementation to allow
variable 'slop'"
Keir Fraser [Thu, 4 Dec 2008 11:36:18 +0000 (11:36 +0000)]
Fix existence check for MMIO-mapped 16550 UARTs
Changeset 982e6fce0e47 added an existence test for UARTs.
Unfortunately, the existence test happens before MMIO UARTs are
ioremapped, therefore it may not be probing where it thinks it's
probing. Rather than moving more code around, I think it's probably
safe to assume the arch code knows what it's doing if it passes in an
MMIO UART.
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Keir Fraser [Thu, 4 Dec 2008 11:31:37 +0000 (11:31 +0000)]
xend: Remember bootloader settings in xenstore
When xend is restarted, bootloader settings of all running domains are
lost. The attached patches fixes this by saving bootloader and
bootloader_args to xenstore database.
Keir Fraser [Wed, 3 Dec 2008 15:55:32 +0000 (15:55 +0000)]
AMD IOMMU: Fix event log interrupt handling
Reset EventLogInt bit in iommu status register(MMIO offset 2020h) in
event log interrupt handler, to show software has handled the
interrupt. Completion wait interrupt is disabled.
Keir Fraser [Wed, 3 Dec 2008 11:44:47 +0000 (11:44 +0000)]
physdev: make PHYSDEVOP_pirq_eoi_mfn use of gmfn instead of mfn.
To pass a page from a guest to hypervisor, gmfn should be used
instead of mfn like grant table and other hypercalls. It's more
consistent. So make use of gmfn instead of mfn for
PHYSDEVOP_pirq_eoi_mfn hypercall.
Itanium processors can handle some misaligned data accesses. They
also provide a mode where all such accesses are forced to trap. The
kernel was schizophrenic about use of this mode:
* Base kernel code ran in permissive mode where the only traps
generated were from those cases that the h/w could not handle.
* Interrupt, syscall and trap code ran in strict mode where all
unaligned accesses caused traps to the 0x5a00 unaligned reference
vector.
Use strict alignment checking throughout the kernel, but make
sure that we continue to let user mode use more relaxed mode
as the default.
Signed-off-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Keir Fraser [Tue, 2 Dec 2008 11:53:24 +0000 (11:53 +0000)]
Fix Xen panic with oprofile
The attached patch fixes a Xen panic when a domain is shutdown before
oprofile is stopped. Without this patch, free_xenoprof_pages() is
called before the domain is destroyed and that, in turn, prevents
oprofile from cleaning up pages shared with guests. Shutting down a
domain without terminating oprofile therefore causes a Xen panic at a
later point in time.
Keir Fraser [Fri, 28 Nov 2008 13:27:32 +0000 (13:27 +0000)]
x86: add a shared page indicating the need for an EOI notification
To simplify the interface for the guest, when a guest uses this new
(sub-)hypercall, PHYSDEVOP_eoi behavior changes to unmask the
corresponding event channel at once, avoiding the eventual need for a
second hypercall from the guest.
Signed-off-by: Jan Beulich <jbeulich@novell.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Keir Fraser [Fri, 28 Nov 2008 13:05:58 +0000 (13:05 +0000)]
xend: Fix device release for tap devices
I saw an error message when I shut down a domain. The error
message showed that release of device(vbd/51712) failed. But the
device was tap, was not vbd. I think that a cause of the error message is
because _releaseDevices() calls destroyDevice() by wrong device class.
Keir Fraser [Fri, 28 Nov 2008 13:04:30 +0000 (13:04 +0000)]
xm: Relax the sanity check on guest configuration with XSM-ACM addlabel
The attached patch relaxes the sanity check on guest configuration
when assigning a acm label to the guest. This patch makes a guest
configuration accept a bootloader parameter. This is common for
paravirtualized guests to boot them by using pygrub.
Keir Fraser [Thu, 27 Nov 2008 16:22:14 +0000 (16:22 +0000)]
x86_emulate: Fix for test harness and simplify some opcodes.
- Need to use EFLG_DF rather than EF_DF
- No need to force EAX destination for many opcodes, as this will be
the default behaviour for DstReg with no ModRM.
Keir Fraser [Thu, 27 Nov 2008 11:22:38 +0000 (11:22 +0000)]
VT-d code cleanup
- remove a printk line. This printk may be output too many on some
platforms, thus result in hang during dom0 booting.
- add write buffer flush in domain_context_unmap_one()
- when map/unmap context, if context is not flushed, needn't to flush
iotlb
Signed-off-by: Weidong Han <weidong.han@intel.com>